import {createStore} from 'vuex'

interface StoreState {
    test2AAAValue: string
    goodsSearchTitle: string
}

// 创建一个vuex的仓库
const store = createStore({
    state() {
        return {
            test2AAAValue: 'bbb',
            goodsSearchTitle: ''
        }
    },
    mutations: {

        changeSearchTitle(state:StoreState, newTitle) {
            state.goodsSearchTitle = newTitle
        },
        /**
         *
         * @param state store的state
         * @param value 第二个值开始就是参数了
         */
        changeTest2AAAValue(state: StoreState, value) {
            console.log('mutations的参数:', arguments)// 打印参数看看
            state.test2AAAValue = value
        }
    }
})

export default store